package com.quanyan.entity;


import com.quanyan.common.GlobalConstValue;
import com.quanyan.util.StringEncode;
import com.quanyan.util.StringUtil;

/**
 * 
 * @ClassName: Command
 * @Description: 命令结构
 * @author chuntu tuchun168@163.com
 * @date 2016年5月3日 上午11:26:22
 *
 */
public class Command {
	private String head = "*Q";

	private String cmd;

	private String data;

	public String getHead() {
		return head;
	}

	public void setHead(String head) {
		this.head = head;
	}

	public String getCmd() {
		return cmd;
	}

	public void setCmd(String cmd) {
		this.cmd = cmd;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "Command{" +
				"head='" + head + '\'' +
				", cmd='" + cmd + '\'' +
				", data='" + data + '\'' +
				'}';
	}

	public int statBytesCounts() {
		int rslt = 0;
		rslt += GlobalConstValue.SHORT_LEN;
		rslt += StringUtil.getStringProtocolLen(cmd, StringEncode.UTF8);
		rslt += StringUtil.getStringProtocolLenINT(data, StringEncode.UTF8);
		return rslt;
	}

}
